<h1>{$params.label} : {$folder->getLabel()}</h1>
<div id="folderLang" style="display:none">{$folder->getLang()}</div>
<div id="folderId" style="display:none">{$folder->getUniqueId()}</div>

<div id="moduleTabs">
    <ul>
	<li><a href="" onclick="return false;"><span>{t}Last edited documents{/t}</span></a></li>
    </ul>
</div>

<div id="ajaxTabLoader"><div id="loaderTabPic">{backend_image file="ajax-loader-big.gif"}</div></div>

<div id="tabContent">
{if count($documents) == 0}
    {if $countFolders == 0}
    <div class="emptyFolder">
        {icon name="info.png"} {t}This module is empty{/t}{hasRight rule=$moduleName|cat:"_Add"} - <a href="{$URL_RELATIVE}/bo/#{url route="addGenericFolder" configModule=$params.configModule docLang=$folder->getLang() docId=$folder->getUniqueId()}" class="greyButton nyroModal">{t}click here to create a new folder{/t}</a>{/hasRight}
    </div>    
    {else}
	<div class="emptyFolder">{icon name="info.png"} {t}This module does not contain any document.{/t}</div>
    {/if}
{else}
    <div id="saveButton" style="display:block" >
        <ul class="saveButtons">
            {hasRight rule=$moduleName|cat:"_Edit"}
            <li class="first">
                <a href="{$URL_RELATIVE}/bo/#/?module=backoffice&action=AjaxDuplicatePublication" class="nyroModalResult">{icon name="documents.png"} {t}Duplicate{/t}</a>
            </li>
            <li>
                <a href="{$URL_RELATIVE}/bo/#/?module=backoffice&action=AjaxSwitchPublicationStatus" class="nyroModalResult">{icon name="refresh.png"} {t}Invert status{/t}</a>
            </li>
            {/hasRight}
            {hasRight rule=$moduleName|cat:"_Delete"}
            <li>
                <a href="{$URL_RELATIVE}/bo/#/?module=backoffice&action=AjaxDeleteFolderContent" class="nyroModalResult delete">{icon name="delete2.png"} {t}Delete{/t}</a>
            </li>
            {/hasRight}
        </ul>
        <div id="selectedelements"></div>
    </div>
    <table class="documentListTable">
	<thead>
	    <tr>
            {hasRight rule=$moduleName|cat:"_Edit "|cat:$moduleName|cat:"_Delete"}
            <th style="width:40px"><input type="checkbox" class="checkAll select" /></th>
            {/hasRight}
            <th colspan="2">{t}Status{/t}</th>
            <th>{t}Label{/t}</th>
            <th>{t}Last modification{/t}</th>
            <th>{t}Folder{/t}</th>
            <th style="width:40px">ID</th>
	    </tr>
	</thead>
	<tbody class="documentListItems">
	{foreach from=$documents key=key item=document name=document}
        {hasDocRight document=$document module=$moduleName rule="read"}
	    {assign var=parent value=$document->getDocumentParent()}
	    <tr {if $smarty.foreach.document.index % 2 == 0}class="even"{else}class="odd"{/if} id="{$document->getUniqueId()}">
            {hasRight rule=$moduleName|cat:"_Edit "|cat:$moduleName|cat:"_Delete"}
            <td style="text-align: center;">
                {hasDocRight document=$document module=$moduleName rule="edit delete"}
                    <input type="checkbox" class="select" value="{$document->getUniqueId()}" name="check_rep[{$key}]" />
                {hasDocRightElse}
                    <input type="checkbox" class="select" value="{$document->getUniqueId()}" name="check_rep[{$key}]" disabled />
                {/hasDocRight}
            </td>
            {/hasRight}
            <td style="width: 40px; text-align: center;" >
                <span class="listButtons">
                    {hasRight rule=$moduleName|cat:"_Delete"}
                    {hasDocRight document=$document module=$moduleName rule="delete"}
                    <a href="{$URL_RELATIVE}/bo/#{url route='deleteGeneric' moduleName=$document->getDocumentModuleName() docId=$document->getUniqueId() docLang=$document->getLang()}" class="nyroModal itemButton itemDeleteButton" title="Supprimer" ></a>
                    {/hasDocRight}
                    {/hasRight}
                    {hasRight rule=$moduleName|cat:"_Edit"}
                    {hasDocRight document=$document module=$moduleName rule="edit"}
                    <a href="{$URL_RELATIVE}/bo/#{$document->getEditUrl()}" class="nyroModal itemButton itemEditButton defaultAction" title="Editer"></a>
                    {/hasDocRight}
                    {/hasRight}
                </span>
            </td>
            <td style="width: 10px; text-align: center;">
                {assign var='status' value=$document->getPublicationStatus()}
                {hasRight rule=$moduleName|cat:"_Edit"}
                    {hasDocRight document=$document module=$moduleName rule="edit"}
                        {publicationStatusSwitch document=$document}
                    {hasDocRightElse}
                        {icon name=status/$status}
                    {/hasDocRight}
                {hasRightElse}
                    {icon name=status/$status}
                {/hasRight}
            </td>
            <td>{$document->getLabel()|truncate:50:"...":true|escape:"html"}</td>
            <td style="width: 230px; text-align: center;">{date date=$document->getModificationDate()|since}</td>
            <td style="width: 120px; text-align: center;"><a href="{$URL_RELATIVE}/bo/#{$parent->getEditUrl()}">{$parent->getLabel()}</a></td>
            <td style="text-align: center">{$document->getUniqueId()}</td>
	    </tr>
        {/hasDocRight}
	{/foreach}
	</tbody>
    </table>
    <div id="result" style="display: none">&folderId={$folder->getUniqueId()}&recursive={$params.deleteRecursive}</div>
    <div id="selectResult" style="display: none"></div>
{/if}
</div>